var t = require("../siteinfo.js"), i = require("./q.js"), r = {
    WebUrl: t.siteroot + "?i=" + t.uniacid + "&from=wxapp&m=group_buy&a=wxapp&c=entry&do=",
    Format: "json"
}, e = function(t, i) {
    for (var r in i) t[r] = i[r];
    return t;
}, n = function(t, r, e) {
    var n = i.defer(), s = "POST" == t ? "application/x-www-form-urlencoded" : "text/html";
    return wx.request({
        url: r,
        method: t,
        data: e,
        header: {
            "Content-Type": s
        },
        success: function(t) {
            n.resolve(t.data);
        },
        fail: function(t) {
            n.reject(t);
        },
        complete: function(t) {
            n.notify(1);
        }
    }), n.promise;
}, s = function(t, i) {
    return n("POST", t, i);
};

module.exports = {
    getUrl: function(t) {
        return r.WebUrl + t;
    },
    getWebUrl: function() {
        return r.WebUrl;
    },
    getParams: function(t, i) {
        t || (t = {}), t.l = r.LanguageMark, t.Format = r.Format;
        var e = wx.getStorageSync("Token") || "";
        return e && (t.Token = e), i && (t.Sign = this.getSign(t)), t;
    },
    Distribution_putpage: function(t) {
        var i = this.getUrl("Distribution_putpage");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_user_info: function(t) {
        var i = this.getUrl("distribution_index");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_team_list: function(t) {
        var i = this.getUrl("distribution_getteam");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_lv: function(t) {
        var i = this.getUrl("distribution_getlv");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_cashlog: function(t) {
        var i = this.getUrl("distribution_cashlog");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    put_dis_cash: function(t) {
        var i = this.getUrl("distribution_cash");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_cash_comment: function(t) {
        var i = this.getUrl("distribution_cashcomment");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_chil_order: function(t) {
        var i = this.getUrl("distribution_getorder");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_corder_num: function(t) {
        var i = this.getUrl("distribution_getordercount");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_config: function(t) {
        var i = this.getUrl("distribution_getconfig");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_commission: function(t) {
        var i = this.getUrl("distribution_getdis_commission");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_commoned_info: function(t) {
        var i = this.getUrl("distribution_commoned_info");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    set_dis_exa: function(t) {
        var i = this.getUrl("distribution_exa");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_commoned_list: function(t) {
        var i = this.getUrl("distribution_commoned_list");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_group_bing: function(t) {
        var i = this.getUrl("distribution_bing");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_commoned_bing: function(t) {
        var i = this.getUrl("distribution_bingcommoned");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    check_user: function(t) {
        var i = this.getUrl("CheckUser");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    },
    get_dis_money_log: function(t) {
        var i = this.getUrl("distribution_moneylog");
        return t = e({}, t), t = this.getParams(t), s(i, t);
    }
};